package ru.susu.algebra.partition.polyhedron.checkers;

import java.math.BigInteger;
import java.util.List;

import ru.susu.algebra.partition.Partition;
import ru.susu.algebra.partition.polyhedron.VertexHelper;
import ru.susu.algebra.partition.vectex.Partition2VertexCache;

/**
 * @author akargapolov
 * @since: 09.03.2010
 */
public class PowVertexChecker implements IVertexChecker
{
	/**
	 * {@inheritDoc}
	 */
	@Override
	public String check(Partition partition, List<Partition> allPartitions)
	{
		Integer[] array = Partition2VertexCache.getVertex(partition);
		int exponent = 0;
		for (int index = 0; index < array.length; index++)
			if (array[index] > 0)
				exponent++;
		BigInteger exp = BigInteger.valueOf(2).pow(exponent);
		return (exp.compareTo(BigInteger.valueOf(array.length + 1)) <= 0) ? CHECKED_RESULT :
			VertexHelper.getVertexString(partition) + " [" + exp + " > " + (array.length + 1) + "]";
	}

}
